<%@ page language="java" %>
<%@ page session="true" %>
<%@ page import="java.sql.*,java.io.*,com.jobportal.MyFunctions"%>
<%
	String Keywords = (request.getParameter("KeyWords")==null)? "" : request.getParameter("KeyWords");
	System.out.println("-->"+Keywords);
	String sCriteria = (request.getParameter("Criteria")==null)? "" : request.getParameter("Criteria");
	System.out.println("-->"+sCriteria);
	String sLocation = (request.getParameter("Location")==null)? "" : request.getParameter("Location");
	System.out.println("-->"+sLocation);
	String sExperience = (request.getParameter("Experience")==null)? "" : request.getParameter("Experience");
	System.out.println("-->"+sExperience);
	String sFunctionalArea = (request.getParameter("FunctionalArea")==null)? "" : request.getParameter("FunctionalArea");
	System.out.println("-->"+sFunctionalArea);
	String SCondition = "";
	SCondition = MyFunctions.getSCondition(Keywords,sCriteria,sLocation,sExperience,sFunctionalArea);
	System.out.println("-->"+SCondition);

%>

<HEAD>


	<script LANGUAGE="Javascript" SRC="Images/validate.js"></script>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
		function fnShowDetails(InterviewID,U)
			{
				var URL = U+"?InterviewID="+InterviewID;
				fnEmpPopUp(URL,600,600);
			}
	//-->
	</SCRIPT>

	<LINK href="styles.css" type="text/css" rel="stylesheet">

</HEAD>
<BODY class="Grad">
<h2 align=center>Search Result</h2>

<%
	Connection con=null;
	ResultSet rs=null;
	Statement stmt=null;
	try{
			
			/* Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection("jdbc:odbc:jobportal","root",""); */

			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jobmiller","root","root");

			stmt =  con.createStatement();
			String Query = "Select * from InterviewDetails";
			if(SCondition!=null && SCondition.trim().equals("")==false){
					Query+=" where "+SCondition;
			}
			Query += " order by Dateofposting";
			System.out.println("Search Query:"+Query);
			rs = stmt.executeQuery(Query);
			%>
						<table align="center" width="60%">
							<tr class=row_title>
								<th align="Center" colspan=4>Job Details</th>
							</tr>
			<%
			int rCount=0;
			while(rs.next())
			{
						String  InterviewID		=rs.getString(1);
						String	JobTitle		=rs.getString(2);
						String	JobDescription	=rs.getString(3);
						String	Eligbility		=rs.getString(4);
						String	Location		=rs.getString(5);
						String	ApplyBefore		=rs.getString(6);
						String	CompanyName		=rs.getString(7);
						String	CompanyProfile	=rs.getString(8);
						String	EmailToApply	=rs.getString(9);
						String	WebSite			=rs.getString(10);
						String	ExecutiveName	=rs.getString(11);
						String	Address			=rs.getString(12);
						String	Telephone		=rs.getString(13);
						String	Fax				=rs.getString(14);
						String	DateOfPosting	=rs.getString(15);
						String	FunctionalArea	=rs.getString(16);
						String	MinExperience	=rs.getString(17);
						String  MaxExperience   =rs.getString(18);

						String Experience = MinExperience+"-"+MaxExperience;
						if(MinExperience.trim().equals(MaxExperience)){
							Experience = MinExperience;
						}
                
					%>
						<TR class= "row_odd">
							<th align="left">Job Id</th> 
							<th align=center><A onclick="fnShowDetails('<%=InterviewID%>','ShowInterview.jsp')"><B>&lt;&lt;<%=InterviewID%>&gt;&gt;</B></th>
							<td align="left" colspan=2><I><FONT SIZE="-1" COLOR="brown" face="Times new roman">click on Job Id to view details and to apply for the job</FONT></I></td> 
						</TR>
						<TR class= "row_even">
							<th align="left">JobTitle</th> <td><%=JobTitle%></td><th align="left">JobDescription</th> <td><%=JobDescription%></td>
						</TR>
						<TR class= "row_even">
							<th align="left">CompanyName</th> <td><%=CompanyName%></td><th align="left">DateOfPosting</th><td><%=DateOfPosting%></td>
						</TR>
						<TR class= "row_even">
							<th align="left">FunctionalArea</th><td><%=FunctionalArea%></td><th align="left">Experience</th><td><%=Experience%> Years</td>
						</TR>
						<TR class= "row_even">
							<th align="center" colspan=4><HR color="#FF0099"></th>
						</TR>
					<%
				rCount++;
			}
			if( rCount == 0)	{%><tr class="row_odd">
										<th align="Center" colspan=4><FONT size="+1" Face="Times new roman" COLOR="#FF0099"><I>Sorry no jobs found, please modify your search criteria and try again</I></FONT></th>
								  </tr><% }
			rs.close();
			stmt.close();
			con.close();
		}catch(Exception e){
			rs.close();
			stmt.close();
			con.close();
			%><%=e%><%
		}
	
%>
</Table>

</BODY>
